﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;

public partial class manager_backupDatabase : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            if (MasApp.BLL.Check.CheckLogin("组织管理员") || MasApp.BLL.Check.CheckLogin("组织账号"))
            {
                form1.Controls.Clear();
                Response.Redirect("~/noaccess.htm");
            }
            TextBox2.Focus();
        }
    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        string name = TextBox2.Text + ".bak";
        string path = TextBox1.Text;
        Label lb = new Label();

        if (File.Exists(path + name))
        {
            name = DateTime.Now.ToString("yyyyMMddHHmmss") + name;
        }
        if (MasApp.BLL.ResponseHelper.BackUpDatabase(name, path))
        {
            lb.Text = "<br />数据库备份文件已成功保存到【 " + path + name + " 】。";
        }
        else
        {
            lb.Text = "<br />数据库备份错误！"
                + "<br /><img src='../images/xitongcuowu.gif' />";
        }
        form1.Controls.Add(lb);
    }
}
